<template>
  <ui-popup
    @onCancel="onCancel"
    @onSubmit="onSubmit"
    :title="params.isEdit ? '修改功能' : '新增功能'"
    width="80%"
    isDrag
    isConfirm
  >
  <el-form ref="updateForm" :model="updateForm" :rules="rules" label-width="80px" inline class="text-left">
    <el-form-item label="功能名称" prop="operationName">
      <el-input v-model.trim="updateForm.operationName" style="width: 260px"></el-input>
    </el-form-item>
    <el-form-item label="功能类型" prop="classification">
      <el-input v-model.trim="updateForm.classification" style="width: 260px"></el-input>
    </el-form-item>
    <el-form-item label="功能编码" prop="operationCode">
      <el-input v-model.trim="updateForm.operationCode" style="width: 260px"></el-input>
    </el-form-item>
  </el-form>
  </ui-popup>
</template>
<script>
export default {
  name: "editOperation",
  props: {
    params: {
      type: Object,
      default() {
        return {};
      }
    }
  },
  data() {
    return {
      //提交的参数
      updateForm: {
        operationName: '',
        classification: '',
        operationCode: '',
      },
      rules: {
        operationName: [
          { required: true, message: '请输入功能名称' }
        ],
        classification: [
          { required: true, message: '请输入功能类型' }
        ],
        operationCode: [
          { required: true, message: '请输入功能编码' }
        ],
      }
    }
  },
  created() {
    if (this.params.isEdit) {
      Object.assign(this.updateForm, this.params)
    }
  },
  methods: {
    onCancel() {
      this.reject();
    },
    onSubmit() {
      let sendData = Object.assign({}, this.$store.getters, this.updateForm);
      this.resolve(sendData);
    },
  }
};
</script>
